package com.llmcu.source.java8.java8inaction.chapter12;

import java.time.LocalTime;

/**
 * LocalTime常用方法
 *
 * @author liuling
 * @date 2024-12-12 10:42
 */
public class LocalTimeDemo {
    public static void main(String[] args) {
        // 1. 通过静态工厂方法创建对象
        LocalTime localTime = LocalTime.of(10, 02, 01);
        int hour = localTime.getHour();
        int minute = localTime.getMinute();
        int second = localTime.getSecond();
        int nano = localTime.getNano();

        // 2. now()方法创建对象
        LocalTime localTime1 = LocalTime.now();

        System.out.println("hour:" + hour);
        System.out.println("minute:" + minute);
        System.out.println("second:" + second);
        System.out.println("nano:" + nano);

        LocalTime localTime2 = LocalTime.of(10, 02, 01, 999_999_999);
        System.out.println("localTime2:" + localTime2);
        // nanoOfSecond范围(valid values 0 - 999_999_999)
        LocalTime localTime3 = LocalTime.of(10, 02, 01, 1_000_000_000);

    }
}
